AC_INIT(gnome-globalmenu, [0.6.9], [rainwoodman@gmail.com], [gnome-globalmenu])

AM_INIT_AUTOMAKE([1.9 tar-ustar])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS(config.h)

# maintainer mode
AM_MAINTAINER_MODE


# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)

# intl
IT_PROG_INTLTOOL
AM_GLIB_GNU_GETTEXT
GETTEXT_PACKAGE=gnome-globalmenu
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"], [gettext package])
AC_SUBST(GETTEXT_PACKAGE)

# Check for Vala
AC_SUBST(VALA_REQUIRED, [0.5.1])
AC_PATH_PROG(VALAC, [valac `pwd`/vala$PATH_SEPARATOR$PATH])

VALA_DEFAULT_PKGS="--vapidir \$(top_srcdir) --pkg configmake"
VALAC="$VALAC $VALA_DEFAULT_PKGS"

AC_CONFIG_COMMANDS_POST(
		[
		VALA_VERSION=`$VALAC --version`
	   	echo $VALA_VERSION | grep $VALA_REQUIRED || \
		AC_MSG_WARN([
			This package works with VALA $VALA_REQUIRED;
			Your have $VALA_VERSION installed;
			You may experience compilation failure or
			random runtime failurs.
			])
		])

# check for modules

GLIB_REQUIRED=2.10.0
GTK_REQUIRED=2.12.0
GIO_REQUIRED=2.12.0

WNCK_REQUIRED=2.24.1
PANEL_REQUIRED=2.24.1

PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)

PKG_CHECK_MODULES(WNCK, libwnck-1.0 >= $WNCK_REQUIRED)
AC_SUBST(WNCK_CFLAGS)
AC_SUBST(WNCK_LIBS)

PKG_CHECK_MODULES(PANEL, libpanelapplet-2.0 >= $PANEL_REQUIRED)
AC_SUBST(PANEL_CFALGS)
AC_SUBST(PANEL_LIBS)

PKG_CHECK_MODULES(GIO, gio-2.0 >= $GIO_REQUIRED gio-unix-2.0 >= $GIO_REQUIRED)
AC_SUBST(GIO_FLAGS)
AC_SUBST(GIO_LIBS)

# path: bad way; move them back to the Makefiles according to GNU rules?

BONOBO_SERVER_DIR="$libdir/bonobo/servers"
AC_SUBST(BONOBO_SERVER_DIR)
AC_DEFINE_UNQUOTED(BONOBO_SERVER_DIR, "$BONOBO_SERVER_DIR", [Where server dir for BONOBO is])

GTK_MODULES_DIR="$libdir/gtk-2.0/modules"
AC_SUBST(GTK_MODULES_DIR)
AC_DEFINE_UNQUOTED(GTK_MODULES_DIR, "$GTK_MODULES_DIR", [Where the gtk-2.0/modules dir is])

# output

AC_CONFIG_FILES(
	[Makefile
	libgnomenu/Makefile
	libgnomenu/tests/Makefile
	applet/Makefile
	tests/Makefile
	gtk-modules/Makefile
	gtk-modules/globalmenu/Makefile
	gtk-modules/globalmenu/tests/Makefile
	po/Makefile.in
	])

AC_OUTPUT
